<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">年份：</label>
                        <div class="layui-input-block">
                            <select id="year" name="year" lay-filter="year">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
<!--                                <div id="search_open" onclick="toggle_search()">-->
<!--                                    <i class="layui-icon layui-icon-down"></i>展开-->
<!--                                </div>-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">

</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>


    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('公司收入台账');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_com_shou_shu),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })
                xiala_zhan_one_you('year', res.data.year, res.data.is_year)

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'topname', title: '款项类型',merge:true}
                ,{field: 'name', title: '款项类型'}
                ,{field: 'year', title: '年度'}
                ,{field:'yearfee',title:'年度合计(元)',totalRow: true,align:'right',event: 'year',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.yearfee)+'</span>';
                    }}
                ,{field:'month1',title:'一月',totalRow: true,align:'right',event: 'dt_1',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month1)+'</span>';}}
                ,{field:'month2',title:'二月',totalRow: true,align:'right',event: 'dt_2',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month2)+'</span>';}}
                ,{field:'month3',title:'三月',totalRow: true,align:'right',event: 'dt_3',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month3)+'</span>';}}
                ,{field:'month4',title:'四月',totalRow: true,align:'right',event: 'dt_4',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month4)+'</span>';}}
                ,{field:'month5',title:'五月',totalRow: true,align:'right',event: 'dt_5',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month5)+'</span>';}}
                ,{field:'month6',title:'六月',totalRow: true,align:'right',event: 'dt_6',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month6)+'</span>';}}
                ,{field:'month7',title:'七月',totalRow: true,align:'right',event: 'dt_7',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month7)+'</span>';}}
                ,{field:'month8',title:'八月',totalRow: true,align:'right',event: 'dt_8',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month8)+'</span>';}}
                ,{field:'month9',title:'九月',totalRow: true,align:'right',event: 'dt_9',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month9)+'</span>';}}
                ,{field:'month10',title:'十月',totalRow: true,align:'right',event: 'dt_10',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month10)+'</span>';}}
                ,{field:'month11',title:'十一月',totalRow: true,align:'right',event: 'dt_11',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month11)+'</span>';}}
                ,{field:'month12',title:'十二月',totalRow: true,align:'right',event: 'dt_12',templet: function(d){return '<span class="colorlan">'+parseFormatNum(d.month12)+'</span>';}}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'year'){
                openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_year);
            }
            if(obj.event === 'dt_1'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_1);}
            if(obj.event === 'dt_2'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_2);}
            if(obj.event === 'dt_3'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_3);}
            if(obj.event === 'dt_4'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_4);}
            if(obj.event === 'dt_5'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_5);}
            if(obj.event === 'dt_6'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_6);}
            if(obj.event === 'dt_7'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_7);}
            if(obj.event === 'dt_8'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_8);}
            if(obj.event === 'dt_9'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_9);}
            if(obj.event === 'dt_10'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_10);}
            if(obj.event === 'dt_11'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_11);}
            if(obj.event === 'dt_12'){openNavPage('查看交易明细信息','account_list/index.php?chanid='+data.id+'&feilei='+data.feilei+'&dt='+data.dt_12);}
        });
        listTableSearch(form, table);
    });



</script>
</body>
</html>
